package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.gametime.L1GameTimeClock;

public class S_OwnCharStatus extends ServerBasePacket {
  private byte[] _byte;
  
  public S_OwnCharStatus(L1PcInstance pc) {
    this._byte = null;
    int time = L1GameTimeClock.getInstance().currentTime().getSeconds();
    time -= time % 300;
    writeC(8);
    writeD(pc.getId());
    writeC(pc.getLevel());
    writeExp(pc.getExp());
    writeC(pc.getStr());
    writeC(pc.getInt());
    writeC(pc.getWis());
    writeC(pc.getDex());
    writeC(pc.getCon());
    writeC(pc.getCha());
    writeH(pc.getCurrentHp());
    writeH(pc.getMaxHp());
    writeH(pc.getCurrentMp());
    writeH(pc.getMaxMp());
    writeC(pc.getAc());
    writeD(time);
    writeC(pc.get_food());
    writeC(pc.getInventory().getWeight240());
    writeH(pc.getLawful());
    writeH(pc.getFire());
    writeH(pc.getWater());
    writeH(pc.getWind());
    writeH(pc.getEarth());
    writeD(pc.getKillCount());
    if (pc.hasSkillEffect(998)) {
      writeC(8);
    } else {
      writeC(0);
    } 
  }
  
  public S_OwnCharStatus(L1PcInstance pc, int str) {
    this._byte = null;
    int time = L1GameTimeClock.getInstance().currentTime().getSeconds();
    time -= time % 300;
    writeC(8);
    writeD(pc.getId());
    writeC(pc.getLevel());
    writeExp(pc.getExp());
    writeC(str);
    writeC(pc.getInt());
    writeC(pc.getWis());
    writeC(pc.getDex());
    writeC(pc.getCon());
    writeC(pc.getCha());
    writeH(pc.getCurrentHp());
    writeH(pc.getMaxHp());
    writeH(pc.getCurrentMp());
    writeH(pc.getMaxMp());
    writeC(pc.getAc());
    writeD(time);
    writeC(pc.get_food());
    writeC(pc.getInventory().getWeight240());
    writeH(pc.getLawful());
    writeH(pc.getFire());
    writeH(pc.getWater());
    writeH(pc.getWind());
    writeH(pc.getEarth());
    if (pc.hasSkillEffect(998)) {
      writeC(8);
    } else {
      writeC(0);
    } 
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
